package com.xuecheng.controller;

import com.xuecheng.po.CourseTeacher;
import com.xuecheng.service.CourseTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class CourseTeacherController {
    @Autowired
    CourseTeacherService courseTeacherService;

    /**
     * 查询教师
     * @param id  课程id
     * @return
     */
    @GetMapping("/courseTeacher/list/{id}")
    public List<CourseTeacher> selectCourseTeacherById(@PathVariable Long id){
        return courseTeacherService.selectCourseTeacherById(id);
    }

    /**
     * 添加教师和修改教师
     * @param courseTeacher
     */
    @PostMapping("/courseTeacher")
    public CourseTeacher saveCourseTeacher(@RequestBody CourseTeacher courseTeacher){

        //机构统一id
        Long company = 1232141425L;
        return courseTeacherService.saveCourseTeacher(company,courseTeacher);
    }

    /**
     * 删除教师
     * @param courseId  课程id
     * @param teacherId  教师id
     */
    @DeleteMapping("/courseTeacher/course/{courseId}/{teacherId}")
    public void deleteCourseTeacher(@PathVariable Long courseId,@PathVariable Long teacherId){
        //机构统一id
        Long company = 1232141425L;
        courseTeacherService.deleteCourseTeacher(company,courseId,teacherId);
    }

}
